<?php


$str = '<img class="rich_pages wxw-img" data-cropselx1="0" data-cropselx2="578" data-cropsely1="0" data-cropsely2="1328" data-ratio="1.2582417582417582" data-src="https://mmbiz.qpic.cn/mmbiz_png/apfq7k1IFugY85VrRGEnAl3Nls5uR5ibuU0Cy1kzx9CiaHRdL0EN4dCib4fhrviadz2IVy5gADbbGqDUA9j375e3lA/640?wx_fmt=png" data-type="jpeg" data-w="728" style="margin: 0px; padding: 0px; max-width: 100%; vertical-align: middle; width: 578px !important; box-sizing: border-box; height: auto !important; display: initial; visibility: visible !important;" data-index="2" data-origin-display="" _width="578px" crossorigin="anonymous" alt="图片" src="https://mmbiz.qpic.cn/mmbiz_png/apfq7k1IFugY85VrRGEnAl3Nls5uR5ibuU0Cy1kzx9CiaHRdL0EN4dCib4fhrviadz2IVy5gADbbGqDUA9j375e3lA/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" data-fail="0">';
//$isMatched = preg_match('/(< img.*?)data-src/', $str, $matches);
//var_dump($isMatched, $matches);
//die();

//
//$string="
//<body>
//<img data-src='222'>
//</body>
//";
$pa="/(<img.*?)data-src/";

$str = preg_replace($pa, '$1src', $str);
var_dump($str);
////die();
//$str="
//<body>
//<img data-src='222'>
//</body>
//$isMatched = preg_match('/(< img.*?)data-src/', $str, $matches);
//var_dump($isMatched, $matches);
//die();
//
//$pattern='';
//$replacement='';
//echo preg_replace($pattern, $replacement, $string);